#include "../inc/inc.h"

int logWrite(char logBuff[])
{
    time_t tLog;
    time(&tLog);
    struct tm *tLocalTime = localtime(&tLog);

    FILE *fpLog = fopen("Shell_Log.txt", "a");
    if ( NULL == fpLog )
    {
        perror("fopen fail");
        return -1;
    }

    fprintf(fpLog, "[%4d-%02d-%02d %02d:%02d:%02d]:%s\n", 
            tLocalTime->tm_year+1900, tLocalTime->tm_mon+1, tLocalTime->tm_mday,
            tLocalTime->tm_hour, tLocalTime->tm_min, tLocalTime->tm_sec,
            logBuff);

    fclose(fpLog);

    return 0;
    
}